package com.reebake.ideal.mybatis.core;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

public class PageResult<T> extends Page<T> {

    public PageResult() {

    }

    public PageResult(long current, long size) {
        this(current, size, 0);
    }

    public PageResult(long current, long size, long total) {
        this(current, size, total, true);
    }

    public PageResult(long current, long size, boolean searchCount) {
        this(current, size, 0, searchCount);
    }

    public PageResult(long current, long size, long total, boolean searchCount) {
        super(current, size, total, searchCount);
    }

    public <V> PageResult<V> to(Class<V> clz) {
        PageResult<V> result = new PageResult<V>(getCurrent(), getSize(), getTotal());
        List<V> records = BeanUtil.copyToList(getRecords(), clz);
        result.setRecords(records);
        return result;
    }

}
